#define _CRT_SECURE_NO_WARNINGS 1

#include"string.h"
#include<string>

void Test_string1()
{
	string s1("hello world");
	
	/*for (auto e : s1)
	{
		cout << e << ' ';
	}
	cout << endl;*/

	/*string::iterator it = s1.begin();
	while (it != s1.end())
	{
		cout << *it << ' ';
		++it;
	}
	cout << endl;*/
}

void Test_string2()
{
	my::string s1("hello world");
	my::string s2;

	s2.append("xxxxxxxxxxx");
	cout << s2.c_str() << endl;
	s1.push_back('y');
	cout << s1.c_str() << endl;

	s1 += s2;
	cout << s1.c_str() << endl;

	s2 += 'i';
	cout << s2.c_str() << endl;
}

void Test_string3()
{
	string s3("hello world");

	s3.assign(9, 'x');
	cout << s3.c_str() << endl;
}

void Test_string4()
{
	my::string s1("hello world");
	s1.insert(5, "xxxxxx");
	cout << s1.c_str() << endl;
	s1.insert(6, 'y');
	cout << s1.c_str() << endl;
	s1.erase(3, 8);
	cout << s1.c_str() << endl;
	s1.replace(6, 3, "hello bit");
	cout << s1.c_str() << endl;

	my::string s2("xxxxxxxx");
	my::string s3("yyyyyyy");
	s2.swap(s3);
	cout << s2.c_str() << endl;
	cout << s3.c_str() << endl;
}

void Test_string5()
{
	my::string s1("hello world");
	my::string s2(s1);
	s2 = s1;
	cout << s1.find("word", 0) << endl;

	my::string s3;
	s3 = s1 + "yyyy";
	cout << s3.c_str() << endl;
	cout << s1.c_str() << endl;
	cout << s1 << endl;

	my::string s4;
	my::string s5;
	cin >> s4 >> s5;

	cout << s4 << endl;
	cout << s5 << endl;
}

int main()
{
	Test_string5();
	return 0;
}